import type { AddressItem, AddressParams } from '@/types/address'
import { http } from '@/utils/http'

//postMemberAddressAPI  提交收货地址
export const postMemberAddressAPI = (data: AddressParams) =>
  http<{ id: number }>({
    method: 'POST',
    url: '/member/address',
    data,
  })

/**
 * 获取收货地址列表
 */
export const getMemberAddressAPI = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}
//收货地址详细 /member/address/{id}
export const getMemberAddressAPIs = (id: string) =>
  http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'GET',
  })
//编辑收货地址
export const putMemberAddressAPI = (id: string, data: AddressParams) =>
  http({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
//删除收货地址
export const delMemberAddressAPI = (id: string) =>
  http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
